import re

phone = '2019-959-559 # 这是一个电话号码'

num = re.sub(r'#.*$',"",phone)

print(num)

num = re.sub(r'\D',"",phone)
print(num)

def double(matched):
    value = int(matched.group('value'))
    return str(value * 2)
s = 'A23G4HFD567'
print(re.sub('(?P<value>\d+)',double,s))

print(s.replace('A','a'))

pattern = re.compile(r'\d+')
m = pattern.match('one12two')
print(m)





